package com.cap.bts.crmdp.dealer.remind.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.crmdp.dealer.remind.dao.ICustomPromotionDao;
import com.cap.bts.crmdp.dealer.remind.domain.CustomPromotion;
import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;
import com.cap.bts.framework.common.exception.AppException;

@Repository("customPromotionDao")
public class CustomPromotionDaoImpl extends BaseDaoImpl<CustomPromotion, Long> implements ICustomPromotionDao {
	
	@Inject
	public CustomPromotionDaoImpl(@Value("com.cap.bts.crmdp.dealer.remind.domain.CustomPromotion") Class<CustomPromotion> clazz) {
		super(clazz);
	}
	
	private static final Logger LOGGER = Logger.getLogger(CustomPromotionDaoImpl.class);

	@Override
	public List<CustomPromotion> getCustomerPromotionByDealerId(Long dealerId,String maintenanceType) throws AppException {
		String sql = "select * from tm_raw_custom_promotion where dealer_id = ' "+ dealerId + "' and maintenance_type = '" + maintenanceType + "'";
		return this.getListByNativeQuery(sql);
	}

	@Override
	public List<CustomPromotion> getCustomerPromotionByPromotion(Long dealerId, String promotion) throws AppException {
		String sql = "select * from tm_raw_custom_promotion where dealer_id = ' "+ dealerId + "'"
				+ " and promotional_content = '" + promotion + "'";
		return this.getListByNativeQuery(sql);
	}

}
